from django.db import models

from utils.base import BaseModel


class Report(BaseModel):

    project = models.ForeignKey('projects.Project', on_delete=models.PROTECT)
    name = models.CharField(verbose_name='套件名称', max_length=50)
    run_env_name = models.CharField(verbose_name='执行环境名称', max_length=30)
    all_case_number = models.IntegerField(verbose_name='总用例数', default=0)
    success_case_number = models.IntegerField(verbose_name='成功用例数', default=0)
    error_case_number = models.IntegerField(verbose_name='错误用例数', default=0)
    fail_case_number = models.IntegerField(verbose_name='失败用例数', default=0)
    api_case_number = models.IntegerField(verbose_name='API用例总数', default=0)
    api_success_case_number = models.IntegerField(verbose_name='API成功用例数', default=0)
    api_fail_case_number = models.IntegerField(verbose_name='API失败用例数', default=0)
    api_error_case_number = models.IntegerField(verbose_name='API错误用例数', default=0)
    ui_case_number = models.IntegerField(verbose_name='UI用例总数', default=0)
    ui_success_case_number = models.IntegerField(verbose_name='UI成功用例数', default=0)
    ui_fail_case_number = models.IntegerField(verbose_name='UI失败用例数', default=0)
    ui_error_case_number = models.IntegerField(verbose_name='UI错误用例数', default=0)
    detail = models.JSONField(default=dict)

    class Meta:
        ordering = ['-create_time']
        db_table = 'tb_report'
        verbose_name = '报告表'
        verbose_name_plural = verbose_name
